<template>
	<view>
		<view class="bg-img">
			<image src="/static/images/success-bg.png" style="width: 100%; height: 350rpx;"></image>
		</view>
		<view class="container">
			<!-- 最上面 -->
			<view class="order-about">
				<view>
					<image src="/static/images/order-details-icon.png" mode="scaleToFill"
						style="width: 35rpx; height: 42rpx;margin-top: 15rpx;">
					</image>
				</view>
				<view style="margin-left: 30rpx;">
					<view style="color: #fff; font-weight: bold; font-size: 35rpx;">{{ orderInfo.status==3?(orderInfo.is_ready_check==1?'审核中':orderInfo.is_ready_check==2?'预审通过':orderInfo.is_ready_check==3?'匹配商家':'待审核'):orderInfo.status_name }}
					</view>
					<view style="color: #fff; font-size: 25rpx;">{{ setData.orderTip }}</view>
				</view>
			</view>
			<!-- 地址 -->
			<view class="address">
				<view class="address-icon" style="display: flex; align-items: center;">
					<image src="/static/images/address.png" mode="widthFix" style="width: 30rpx;">
					</image>
				</view>
				<view class="address-detail">
					<view class="user-info">
						<view>收货人： {{ orderInfo.realname }}</view>
						<view>{{ orderInfo.mobile }}</view>
					</view>
					<view class="user-address">
						<view style="line-height: 1.2rem; display: flex;">
							<view style="white-space: nowrap;">地址：</view>
							<view style="word-break: break-all;">{{ orderInfo.address }}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 选择监管设备 -->
			<view class="phoneType" v-if="orderInfo.is_ready_check==2&&orderInfo.status==3">
				<view class="flex">
					<view class="" style="color: #E43C3A;font-size: 28rpx;">
						*
					</view>
					<view class="" style="color: #333333;font-size: 28rpx;">
						请选择是否接受监管设备
					</view>
				</view>
				<view class="" style="font-size: 25rpx;color:#888;padding-bottom:10rpx;padding-left:20rpx">
					平台根据您的信用情况可能调整租期、租金以及租赁方案；请在选择前仔细查看本页面订单内容。
				</view>
				<view class="">
					<radio-group name="" @change="handleChange">
						<view class="flex">
							<view :class="acceptFlag==true?'accepted':'accept'" style="width: 350rpx;">
								<label>
									<view class="accept_font" style="font-weight:800;font-size:35rpx">
										审核通过(接受)
									</view>
									<view class="flex flex-center" style="font-size:28rpx;">
										<view class="" style="display: flex;justify-content: center;align-items: center;">
											<image :src="acceptFlag==false?'/static/images/a05.png':'/static/images/a03.png'"
												style="width: 30rpx;height: 30rpx;" mode=""></image>
										</view>
										<view class="">
											押金：{{orderInfo.fraud_price}}元
										</view>
									</view>
									<view style="font-size:20rpx;">
										(含第1期租金{{orderInfo.first_rent}}元)
									</view>
									<view class="flex flex-center" style="font-size:28rpx;">
										<view style="display: flex;justify-content: center;align-items: center;">
											<image :src="acceptFlag==false?'/static/images/a06.png':'/static/images/a04.png'"
												style="width: 30rpx;height: 30rpx;" mode=""></image>
										</view>
										<view class="">
											押金可抵扣租金
										</view>
									</view>
									<view class="tips">
										<view style="">
											温馨提示:
										</view>
										<view>
											平台都为国行正品手机，在使用上和正常手机无任何区别，若您发生逾期行为，平台有权冻结或结束租赁服务并对设备进行锁定，在您正常履约后平台会结束设备锁定。
										</view>
									</view>
									<radio value="监管机" color="#1DB03C" checked />
									<view style="font-size: 22rpx;">我接受当前租赁设备为监管设备</view>

								</label>
							</view>
							<view :class="no_acceptFlag==false?'no_accept':'no_accepted'">
								<label>
									<view class="accept_font" style="font-weight:800;font-size:35rpx">
										不接受
									</view>
									<view class="flex flex-center" style="font-size:28rpx;">
										<view style="display: flex;justify-content: center;align-items: center;">
											<image :src="no_acceptFlag==false?'/static/images/a05.png':'/static/images/a01.png'"
												style="width: 30rpx;height: 30rpx;" mode=""></image>
										</view>
										<view>
											押金：{{orderInfo.fraud_price}}元
										</view>
									</view>
									<view style="font-size:20rpx;">
										(含第1期租金{{orderInfo.first_rent}}元)
									</view>
									<view style="font-size:22rpx">
										以人工审核为准 可能高于{{orderInfo.fraud_price}}元
									</view>
									<view class="flex flex-center" style="font-size:28rpx;">
										<view style="display: flex;justify-content: center;align-items: center;">
											<image :src="no_acceptFlag==false?'/static/images/a06.png':'/static/images/a02.png'"
												style="width: 30rpx;height: 30rpx;" mode=""></image>
										</view>
										<view class="">
											押金可抵扣租金
										</view>
									</view>
									<view class="tips" style="height:178rpx;">
										<view>
											温馨提示:
										</view>
										<view>
											审核人员 会在24小时内电话联系您，可注意接听！
										</view>
									</view>
									<view class="">
										<radio value="非监管机" color="#E43C3A" />
										<view style="font-size: 22rpx;">
											转人工审核
										</view>
									</view>

								</label>
							</view>
						</view>
					</radio-group>
				</view>
			</view>
			<!-- 商品信息 -->
			<view class="goods-detail">
				<view class="goods-detail-top">
					<view @click="handleShop(orderInfo.member_id)">
						<uni-icons type="shop"></uni-icons>
						<text style="margin-left: 25rpx;">{{ orderInfo.shopname }}</text>
					</view>
					<image class="more" src="@/static/images/more.png" mode="widthFix"></image>
				</view>
				<view class="divider"></view>
				<!-- <view class="goods-detail-bottom" @click="toOrderDetailAbout"> -->
				<view class="goods-detail-bottom">
					<view class="goods-img">
						<image :src="orderInfo.imgurl" style="height: 180rpx; width: 180rpx;">
						</image>
					</view>
					<view class="goods-info">
						<view>{{ orderInfo.goods_title }}</view>
						<view class="text-color">套餐： {{ orderInfo.setmeal_title }}</view>
						<view class="text-color">租期： {{ orderInfo.lease_time }}</view>
						<view class="text-color">数量： {{ orderInfo.amount }}</view>
					</view>
				</view>
			</view>
			<!-- 租赁套餐 -->
			<view class="order-plan">
				<view>租赁套餐</view>
				<view>{{ orderInfo.pact_type_name }}</view>
			</view>
			<!-- 金额 -->
			<view class="order-money">
				<view class="order-money-top">
					<view>首期实付金额</view>
					<view style="color: red;">￥{{ orderInfo.first_paid_rent }}</view>
				</view>
				<view class="order-money-bottom">
					<view class="order-money-bottom-item">
						<view class="left">总租金</view>
						<view class="right">￥{{ orderInfo.rent_total }}</view>
					</view>
					<view class="order-money-bottom-item">
						<view class="left text-color">首期租金</view>
						<view class="right text-color">￥{{ orderInfo.first_rent }}（第1期）</view>
					</view>
					<view class="order-money-bottom-item">
						<view class="left text-color">已还租期</view>
						<view class="right text-color">￥{{ orderInfo.paid_total_rent }}（共{{ orderInfo.month_paid }}期）
						</view>
					</view>
					<view class="order-money-bottom-item">
						<view class="left text-color">剩余租期</view>
						<view class="right text-color">￥{{ orderInfo.last_rent }}（共{{ orderInfo.last_term }}期）</view>
					</view>
				</view>
				<view class="order-detail" @click="toBillDetail">
					<view class="detail-title">
						账单详细
					</view>
					<image class="detail-img" src="@/static/images/more.png" mode="widthFix">
					</image>
				</view>
			</view>
			<!--  -->
			<view class="model">
				<view class="become_due">
					<view class="title">到期买断金额</view>
					<view class="price">
						￥{{ orderInfo.setmeal_price }}
					</view>
				</view>
				<view class="express">
					<view class="title">配送方式</view>
					<view class="way">
						{{ orderInfo.convey_type }}
					</view>
				</view>
			</view>
			<!-- 备注 -->
			<view class="remarks">
				<view class="title">备注</view>
				<view class="val">{{ orderInfo.remark }}</view>
			</view>
			<!-- 协议 -->
			<view class="bottom-box">
				<view class="item">
					<view class="title">租赁协议</view>
					<view class="right" @click="toAgreement">
						<view class="watch">查看协议</view>
						<image class="more" src="@/static/images/more.png" mode="widthFix"></image>
					</view>
				</view>
				<view class="item">
					<view class="title">订单编号</view>
					<view class="right" @click="handleCopy(orderInfo.trade_no)">
						<view class="hash">{{ orderInfo.trade_no }}</view>
						<image class="copy" src="@/static/images/copy.png" mode="widthFix"></image>
					</view>
				</view>
				<view class="item">
					<view class="title">创建时间</view>
					<view class="right">
						{{ orderInfo.create_time }}
					</view>
				</view>
			</view>
			<!-- 底部操作 -->
			<view class="change">
				<view class="more" v-if="btns(orderInfo.status).length > 3" @click="handleMore">
					更多
					<view class="contact" v-show="showMore" @click.stop="handleService">联系客服</view>
				</view>
				<view class="btn" v-for="(ele,index) in btns(orderInfo.status,acceptNums)" :key="index"
					:class="[ele.class,index > 2 ? 'hide' : '',showMore ? 'show' : '']" @click="handleBtn(ele.name)">
					{{ele.name}}
				</view>
			</view>
		</view>
		<!-- 普通弹窗 -->
		<uni-popup ref="popup" background-color="#fff">
			<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
				<uni-section title="请选择支付方式" type="line">
					<uni-data-select :localdata="uniCode" @change="change"></uni-data-select>
				</uni-section>
			</view>
		</uni-popup>
		<!-- 普通弹窗 -->
		<uni-popup ref="popup1" background-color="#fff">
			<view class="popup-content1" :class="{ 'popup-height': type1 === 'left' || type1 === 'right' }">
				<uni-section title="请选择支付银行卡" type="line">
					<uni-data-select :localdata="uniCode1" @change="change1"></uni-data-select>
				</uni-section>
				<uni-section title="请输入验证码" type="line">
					<input type="text" placeholder="请输入验证码" :value="payCode"
						style="border: solid 1px #e5e5e5;height: 65rpx;width: 400rpx;">
					<button class="code_btn" :disabled="isSend1" @click="handleCode">{{codeName}}</button>
				</uni-section>
				<view class="" style="margin-top: -25rpx;">
					<button type="default" @click="goPay1">确认支付</button>
				</view>
			</view>
		</uni-popup>
		<!-- 申请归还弹窗 -->
		<uni-popup ref="returnBack" background-color="#fff" type="dialog">
			<view :class="{ 'popup-height': returnType === 'left' || returnType === 'right' }">
				<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认归还"
					:title="this.item.status==40 || this.item.status==42 ? '订单到期！' :'订单未到期！'"
					content="是否确认归还商品？\n请在到期3天内归还，以免对您的押金退还造成影响。" @confirm="dialogApply" @close="dialogClose"></uni-popup-dialog>
			</view>
		</uni-popup>
		<uni-popup ref="returnBack1" background-color="#fff" type="dialog">
			<view :class="{ 'popup-height': returnType === 'left' || returnType === 'right' }">
				<uni-popup-dialog :type="msgType" cancelText="取消申请" confirmText="确认申请"
					:title="this.item.status==40 || this.item.status==42 ? '订单到期！' :'订单未到期！'"
					content="该商品允许提前归还，是否确认申请提前归还？\n归还后已缴付的租金不再退还，如有疑问请联系商家。" @confirm="dialogApply"
					@close="dialogClose"></uni-popup-dialog>
			</view>
		</uni-popup>
		<!-- 添加物流弹窗 -->
		<uni-popup ref="addLogistics" background-color="#fff" type="dialog">
			<view style="width:650rpx ;" :class="{ 'popup-height': type1 === 'left' || type1 === 'right' }">
				<uni-section title="请选择物流名称" type="line">
					<uni-data-select :localdata="flowList" @change="changeFlow"></uni-data-select>
				</uni-section>
				<uni-section title="请输入物流单号" type="line">
					<input type="text" placeholder="请输入物流单号" :value="flowNumber" @input="handleFlow"
						style="border: solid 1px #e5e5e5;height: 65rpx;">
				</uni-section>
				<view class="" style="margin-top: 20rpx;">
					<button type="default" @click="toFlow">确认添加</button>
				</view>
			</view>
		</uni-popup>
	</view>

</template>

<script>
	import orderState from "@/common/my-goods-order/orderState.js";
	import redState from "@/common/my-goods-order/redState.js";
	import {
		orderInfo,
		readyPay,
		confirmPay,
		createContract,
		wechatPay,
		orderApplyReturn,
		getReturnExpressList,
		orderReturnCancel,
		orderReturnAddExpress,
		cancelOrderRefund,
		orderPay1,
		confirmFraud
	} from '@/api/order'
	import {
		debounce
	} from '@/utils/debounce'
	export default {
		data() {
			return {
				id: null, //订单id
				setData: {}, //提示信息
				orderInfo: {}, //订单信息
				showMore: false,
				flowList: [],
				flowNumber: '',
				flowName: '',
				flowIndex: '',
				type1: '',
				acceptFlag: true,
				no_acceptFlag: false,
				acceptNums:0,
				timmerFlag:''
			}
		},
		onLoad(options) {
			this.id = options.order_id
			this.getOrderInfo()
		},
		onPullDownRefresh() {
			orderInfo({
				order_id: this.id
			}).then(res => {

			})
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			handleChange(e) {
				// 支付押金
				let arr24=orderState.filter(item=>item.id==26)
				// 确定
				let arr25=orderState.filter(item=>item.id==25)
				if (e.detail.value == '监管机') {
					this.acceptFlag = true
					this.no_acceptFlag = false
					this.acceptNums = 2
					orderState.forEach(e=>{
						if(e.id==26){
							this.btns(e.status,this.acceptNums)
							return
						}
					})
				} else {
					this.no_acceptFlag = true
					this.acceptFlag = false
					this.acceptNums = 1
				}
			},
			rewriteOrder() {
				uni.navigateTo({
					url: `/pagesA/category/goods/productDetails/productDetails?id=${this.orderInfo.goods_id }`
				})
			},
			handleBtn(name) {
				switch (name) {
					case "联系客服":
						this.handleService();
						break;
					case "再次下单":
						this.rewriteOrder();
						break;
					case "取消订单":
						this.cancelOrder();
						break;
					case "立即付款":
						this.payOrder();
						break;
					case "签署合同":
						this.goSign();
						break;
					case "申请退款":
						this.toApply();
						break;
					case "支付租金":
						this.toPay();
						break;
					case "申请归还":
						this.returnBack();
						break;
					case "取消归还":
						this.canleBack();
						break;
					case "取消退款":
						this.canlePay();
						break;
					case "申请续租":
						this.applyLease();
						break;
					case "协议公证":
						this.notarization();
						break;
					case "上传证件":
						this.cardSubmit();
						break;
					case "确定":
						this.pay();
						break;
					case "去提交":
						this.cancleSubmit();
						break;
				}
			},
			// 去提交
			cancleSubmit(){
				console.log(this.orderInfo);
				if(this.orderInfo.is_fraud==1){
					let data={
						orderId:this.orderInfo.order_id,
						is_supervise:this.acceptNums
					}
					confirmFraud(data).then(res=>{
						uni.showToast({
							title:'提交成功'
						})
						this.getOrderInfo()
					})
				}else{
					uni.$http.post('/Wechat/Order/orderCancel', {
						order_id: this.orderInfo.order_id
					}).then(res => {
						if (res.data.status === 200) {
							uni.hideLoading();
							uni.$emit("deleteItem", this.orderInfo.id);
							uni.showToast({
								title: res.data.msg,
								icon: "none",
							})
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: "error",
							})
						}
					}).finally(() => {
						uni.hideLoading();
						this.getOrderInfo()
					})
				}
			},
			// 支付押金
			pay(){
				if(this.acceptNums==0){
					uni.showToast({
						title:'请选择机型'
					})
					return
				}else{
					let data = {
						orderId:this.id,
						is_supervise:this.acceptNums
					}
					confirmFraud(data).then(res=>{
						uni.showToast({
							title:'提交成功'
						})
						this.getOrderInfo()
					})
					// orderPay1(data).then(res=>{
					// 		let appId = res.appid
					// 		let timeStamp = res.timeStamp + ''
					// 		let nonceStr = res.nonce_str
					// 		let packageX = res.prepay_id
					// 		let signType = 'MD5'
					// 		let paySign = res.paySign
					// 		uni.requestPayment({
					// 			"provider": "wxpay",
					// 			appId: appId,
					// 			prepay_id: packageX,
					// 			nonceStr: nonceStr,
					// 			package: 'prepay_id=' + packageX,
					// 			timeStamp: timeStamp,
					// 			paySign: paySign,
					// 			signType: 'MD5',
					// 			success(res) {
					// 				console.log('success', res);
					// 				uni.reLaunch({
					// 					url:'/pagesA/my/order/myorder/myorder?id=0&active=0'
					// 				})
					// 			},
					// 			fail(e) {
					// 				console.log('fail', e);
					// 			}
					// 		})
					// })
				}
			},
			// 上传身份证照片
			cardSubmit() {
				uni.navigateTo({
					url: '/pagesB/userCard/userCard'
				})
			},
			// 申请续租
			applyLease() {

				this.$refs.applyLease.open(this.returnType)
			},
			// 协议公证
			notarization() {
				uni.navigateTo({
					url: '/pagesB/notarization/notarization?orderId=' + this.orderInfo.order_id
				})
			},
			btns(status,nums) {
					let data = [];
				if(nums==2){
					data=orderState.filter(item=>item.id==2||item.id==24||item.id==26)
					console.log(data.sort(this.compare('id', true)));
					return data;
				}else if(nums==1){
					data=orderState.filter(item=>item.id==2||item.id==24||item.id==25)
					console.log(data.sort(this.compare('id', true)));
					return data;
				}else{
					orderState.forEach(item => {
						if(this.orderInfo.is_ready_check!=2&&item.id==26){
							data.shift(item)
							return 
						}else{
							const bool = item.status.includes(status);
							if (bool) {
								if (redState.includes(item.name)) {
									item.class = 'red';
								}
								data.unshift(item);
							}
						}
					})
					console.log(data.sort(this.compare('id', true)));
					return data.filter(item=>item.id!=25);
				}
				
			},
			compare (attr,rev) {
			      // console.log(attr, rev)
			      if(rev ==  undefined){
			          rev = 1;
			      }else{
			          rev = (rev) ? 1 : -1;
			      }
			      return (a,b) => {
			          a = a[attr];
			          b = b[attr];
			          if(a < b){
			              return rev * -1;
			          }
			          if(a > b){
			              return rev * 1;
			          }
			          return 0;
			      }
						},
			handleService() {
				uni.switchTab({
					url: "/pages/service/service",
				})
			},
			// 取消退款
			canlePay() {
				cancelOrderRefund(this.orderInfo.order_id).then(res => {
					uni.showToast({
						icon: 'success',
						title: '操作成功',
					});
				})
			},
			// 取消归还
			canleBack: debounce(function() {
				orderReturnCancel(this.orderInfo.order_id).then(res => {
					showModal
					this.onPullDownRefresh()
				})
			}, 500),
			handleFlow(e) {
				let reg = /^[0-9A-Za-z]+$/
				if (!reg.test(e.detail.value)) {
					my.showToast({
						icon: 'error',
						title: '请填写正确的物流单号',
					});
				}
				this.flowNumber = e.detail.value
			},
			changeFlow(e) {
				this.flowIndex = e
				this.flowName = e
			},
			toFlow() {
				let reg = /^[0-9A-Za-z]+$/
				if (this.flowIndex < -1) {
					uni.showToast({
						title: '请选择物流名称',
						icon: 'error'
					})
					return false
				}
				if (!this.flowNumber && this.flowIndex == '') {
					my.showToast({
						icon: 'error',
						title: '请填写物流单号',
					});
					return false
				}
				if (this.flowNumber && !reg.test(this.flowNumber)) {
					my.showToast({
						icon: 'error',
						title: '请填写正确的物流单号',
					});
					return false
				}
				orderReturnAddExpress({
					order_id: this.orderInfo.order_id,
					logistics_name: this.flowList[this.flowName].text,
					logistics_no: this.flowNumber,
				}).then(res => {
					this.$refs.addLogistics.close()
					// 刷新当前页面
				})
			},
			// 申请归还
			returnBack() {
				if (this.orderInfo.status == 40 || this.orderInfo.status == 42) {
					this.$refs.returnBack.open(this.returnType)
				} else {
					this.$refs.returnBack1.open(this.returnType)
				}

			},
			dialogClose() {},
			dialogApply() {
				if (this.orderInfo.status == 40) {
					getReturnExpressList().then(res => {
						this.$refs.returnBack.close()
						this.$refs.addLogistics.open(this.returnType)
						for (let i = 0; i < res.length; i++) {
							this.flowList.push({
								value: i,
								text: res[i].name
							})
						}
					})
				} else if (this.orderInfo.status == 30 || this.orderInfo.status == 39) {
					orderApplyReturn(this.orderInfo.order_id).then(res => {
						my.showToast({
							icon: 'success',
							title: '操作成功',
						});
						// 需要添加一个刷新列表操作
						this.$refs.returnBack1.close()
					})
				}
			},
			toPay() {
				uni.navigateTo({
					url: '/pagesA/my/order/myorder/payRent?order_id=' + this.id + '&isView=true'
				})
			},
			handleMore() {
				this.showMore = !this.showMore;
			},
			cancelOrder() {
				uni.showLoading({
					title: "Loading",
					mask: true,
				})
				uni.$http.post('/Wechat/Order/orderCancel', {
					order_id: this.item.id
				}).then(res => {
					if (res.data.status === 200) {
						uni.hideLoading();
						uni.$emit("deleteItem", this.item.id);
						uni.showToast({
							title: res.data.msg,
							icon: "none",
						})
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: "error",
						})
					}
				}).finally(() => {
					uni.hideLoading();

				})
			},
			// 立即付款
			payOrder() {
				this.type = 'center'
				this.$refs.popup.open(this.type)
			},
			goPay1() {
				if (this.payCode == '') {
					uni.showToast({
						title: "请先输入验证码",
						icon: 'error'
					})
					return
				}
				let data1 = {
					leaseId: this.selected,
					orderId: this.order,
					unique_code3: this.unique_code3,
					code: this.payCode
				}
				confirmPay(data1).then(res => {
					if (res.status == 200) {
						uni.showToast({
							title: "支付成功",
							icon: 'success'
						})
						this.$refs.popup.close()
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'error'
						})
						this.$refs.popup.close()
					}
				})
			},
			change1(e) {
				this.unique_code2 = e
			},
			change(e) {
				if (e == 1) {
					// 请求接口拿回数据---------微信支付
					let data = {
						orderId: this.item.id,
						total_fee: this.item.rent * 100,
						leaseId: ['1']
					}
					wechatPay(data).then(res => {
						let appId = res.appid
						let timeStamp = res.timeStamp + ''
						let nonceStr = res.nonce_str
						let packageX = res.prepay_id
						let signType = 'MD5'
						let paySign = res.paySign
						uni.requestPayment({
							"provider": "wxpay",
							appId: appId,
							prepay_id: packageX,
							nonceStr: nonceStr,
							package: 'prepay_id=' + packageX,
							timeStamp: timeStamp,
							paySign: paySign,
							signType: 'MD5',
							success(res) {
								console.log('success', res);
							},
							fail(e) {
								console.log('fail', e);
							}
						})
					})
				} else {
					this.$refs.popup.close()
					this.$refs.popup1.open(this.type1)
					console.log(1);
				}
			},
			// 签署合同
			goSign: debounce(function(e) {
				uni.showLoading({
					title: "Loading",
					mask: true,
				})
				let data = {
					order_id: this.item.id
				}
				createContract(data).then(res => {
					if (res.type == '1') {
						uni.hideLoading();
						uni.showModal({
							title: res.msg,
							content: '绑定银行卡',
							success: function(res) {
								if (res.confirm) {
									uni.navigateTo({
										url: '/pagesB/addBank/addBank'
									})
								} else if (res.cancel) {
									uni.showToast({
										title: '请先完成绑卡',
										icon: 'error'
									})
								}
							}
						})
					} else {
						uni.hideLoading();
						this.flowId = res.flowId
						this.signerId = res.signerId
						uni.navigateToMiniProgram({
							appId: 'wx1cf2708c2de46337', // 公证签小程序APPID
							path: '/pages/index/index', // webview页面地址
							extraData: {
								// 入参
								requestObj: {
									flowId: res.flowId, // 签署/实名流程id
									accountId: res.signerId, // 账号id（仅签署需要）
									type: 'SIGN', // 业务类型：签署 SIGN（默认）, 实名 REALNAME
									env: 'prod', // 对接环境：线上 prod(默认）, 模拟 sml(用于对接调试阶段）
								},
								// 回传数据：签署/实名完成后会将此数据完整回传
								callbackObj: {
									test: '12345',
									'from': 'SIGN'
								},
							},
							success(res) {
								// 根据客户自身需要
							},
							fail(res) {
								// 根据客户自身需要
							},
							complete(res) {
								// 根据客户自身需要
							},
						})
					}
				})
			}, 2000),
			// 申请退款
			toApply: debounce(function(e) {
				uni.navigateTo({
					url: '/pagesB/applyRefund/applyRefund?order_id=' + this.item.id
				})
			}, 100),
			handleCopy(value) {
				uni.setClipboardData({
					data: value,
					success: () => {
						uni.$showMsg('复制成功')
					},
				})
			},
			toBillDetail() {
				uni.navigateTo({
					url: `/pagesA/my/order/myorder/payRent?order_id=${this.id}&title=${this.orderInfo.title}&isView=false`
				})
			},
			toAgreement() {
				uni.navigateTo({
					url: '/pagesA/my/agreement/agreement'
				})
			},
			handleShop(member_id) {
				uni.navigateTo({
					url: `/pagesB/shopmall/mallIndex?member_id=${member_id}`
				})
			},
			/* toOrderDetailAbout() {
				uni.navigateTo({
					url: `/pagesA/my/order/myorder/orderDetailAbout?orderInfo=${JSON.stringify(this.orderInfo)}&order_id=${this.id}`
				})
			}, */
			toShopMall() {
				uni.navigateTo({
					url: '/pages/shopmall/mallIndex'
				})
			},
			async getOrderInfo() {
				const {
					data: res
				} = await uni.$http.get(`/Wechat/Order/orderInfo?order_id=${this.id}`)
				this.orderInfo = res.data
				this.orderInfo.imgurl = getApp().globalData.baseImg + this.orderInfo.imgurl
				getApp().globalData.member_id = this.orderInfo.member_id //测试用的会员id，会删
				this.getOrderTip(this.orderInfo.status, this.orderInfo.is_amount_apply,this.orderInfo.is_ready_check)
			},
			getOrderTip(status, is_amount_apply,is_ready_check) {
				switch (status) {
					case 2:
						if (is_amount_apply == 2) {
							this.setData = {
								orderTip: '预计两个小时后自动关闭订单，请及时处理'
							};
						} else {
							this.setData = {
								orderTip: '已申请押金减免,请耐心等待审核！'
							};
						}
						break;
					case 3:
						if(is_ready_check==1){
							this.setData = {
								orderTip: '系统正在为您审核中'
							};
							}else if(is_ready_check==2){
							this.setData = {
								orderTip: '请在24小时内选择是否接受监管设备'
							};
							}else if(is_ready_check==3){
							this.setData = {
								orderTip: '系统正在为您匹配发货商家'
							};
							}else{
							this.setData = {
								orderTip: '请等待人工审核'
							};
							}
						break;
					case 10:
						this.setData = {
							orderTip: '审核发货预计需要3个工作日，请保持手机畅通'
						};
						break;
					case 11:
						this.setData = {
							orderTip: '审核退款预计1—3个工作日，请保持手机畅通'
						};
						break;
					case 20:
						this.setData = {
							orderTip: '您的订单已发货，请及时收货'
						};
						break;
					case 1:
						this.setData = {
							orderTip: '您的订单已取消'
						};
						break;
					case 60:
						this.setData = {
							orderTip: '您的订单已完成'
						};
						break;
					case 30:
						const {
							lease_time, month_total
						} = this.orderInfo;
						const tip = '您的订单租期：' + lease_time + '（共' + month_total + '月）到期后请及时处理（归还、续租、买断）';
						this.setData = {
							orderTip: tip
						};
						break;
					case 13:
						this.setData = {
							orderTip: '商家拒绝退款，拒绝原因：'
						};
						break;
					case 16:
						const {
							setmeal_foregift, pay_type
						} = this.orderInfo;
						this.setData = {
							orderTip: '您的订单已退款' + (pay_type == 2 ? '，已退回冻结押金￥' + setmeal_foregift : '')
						}
						break;
					case 41:
						this.setData = {
							orderTip: '您已申请归还，请主动联系商家进行处理，商家会在3个工作日内确认是否同意归还。'
						}
						break;
					case 42:
						this.setData = {
							orderTip: '商家已同意归还，请填写归还物流信息'
						}
						break;
					case 44:
						this.setData = {
							orderTip: '您已发货，等待商家收货'
						}
						break;
					case 45:
						this.setData = {
							orderTip: '商家已确认收货'
						}
						break;
					case 43:
						this.setData = {
							orderTip: '商家未同意归还，请联系商家'
						}
						break;
					case 62:
						const {
							buyout_amount
						} = this.orderInfo;
						this.setData = {
							orderTip: '实付买断金额：￥' + buyout_amount
						};
						break;
					default:
						break;
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.phoneType {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 20rpx;
		margin-top: 30rpx;
	}

	.accept {
		width: 300rpx;
		border-radius: 20rpx;
		text-align: center;
		margin-right: 20rpx;
		color: #888888;
		border: 1px solid #888888;
		background: rgba(136, 136, 136, 0.03);
		border-radius: 8px 8px 8px 8px;
	}

	.accepted {
		width: 300rpx;
		border-radius: 20rpx;
		text-align: center;
		margin-right: 20rpx;
		color: #1DB03C;
		border: 1px solid #1DB03C;
		background: #1db03c0a;
		border-radius: 8px 8px 8px 8px;
	}

	.no_accept {
		width: 300rpx;
		color: #888;
		border: 1px solid #888888;
		background: rgba(136, 136, 136, 0.03);
		border-radius: 8px 8px 8px 8px;
		text-align: center
	}

	.no_accepted {
		width: 300rpx;
		color: #E43C3A;
		border: 1px solid #E43C3A;
		background: rgba(228, 60, 58, 0.03);
		border-radius: 8px 8px 8px 8px;
		text-align: center
	}

	.tips {
		font-size: 25rpx;
		color: #666666;
		text-align: left;
		padding-left: 10rpx;
	}

	.container {
		padding: 30rpx;
		position: relative;
		margin-top: -310rpx;
		font-size: 25rpx;
	}

	.order-about {
		background-color: rgba(0, 0, 0, 0);
		display: flex;
		justify-content: start;
		line-height: 2rem;
	}

	.address {
		display: flex;
		flex-direction: row;
		padding: 30rpx;
		border-radius: 20rpx;
		background-color: #fff;
		margin-top: 40rpx;
	}

	.address-detail {
		margin-left: 20rpx;
		width: 580rpx;
	}

	.user-info {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 10rpx;
	}

	.goods-detail {
		border-radius: 20rpx;
		margin-top: 20rpx;
		background-color: #fff;
	}

	.goods-detail-top {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;

		.more {
			width: 12rpx;
			height: 12rpx;
		}
	}

	.divider {
		width: 100%;
		height: 1px;
		background-color: #eee;
	}

	.goods-detail-bottom {
		display: flex;
		flex-direction: row;
		justify-content: start;
		padding: 20rpx;
	}

	.goods-info {
		margin-left: 10rpx;
	}

	.order-plan {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 25rpx 20rpx;
		border-radius: 15rpx;
		background-color: #fff;
		margin-top: 20rpx;
	}

	.order-money {
		background-color: #fff;
		border-radius: 20rpx;
		margin-top: 20rpx;
		padding: 20rpx;
	}

	.order-money-top {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.order-money-bottom {
		background-color: #eee;
		border-radius: 20rpx;
		padding: 20rpx;
		margin-top: 20rpx;
	}

	.order-money-bottom-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		line-height: 2rem;
	}

	.text-color {
		color: #999;
		font-size: 25rpx;
	}

	.order-detail {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-top: 20rpx;

		.detail-img {
			width: 12rpx;
			height: 12rpx;
		}
	}

	.model {
		background-color: white;
		margin-top: 20rpx;
		border-radius: 15rpx;

		.become_due {
			border-bottom: 1rpx solid #eee;
		}

		.become_due,
		.express {
			padding: 25rpx 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		.price,
		.way {
			color: #999;
		}
	}

	.remarks {
		padding: 25rpx 20rpx;
		margin-top: 20rpx;
		background-color: white;
		border-radius: 10rpx;
		display: flex;

		.title {
			margin-right: 20rpx;
		}

		.val {
			color: #999;
		}
	}

	.bottom-box {
		background-color: white;
		border-radius: 20rpx;
		margin-top: 20rpx;
		margin-bottom: 90rpx;

		.item {
			padding: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.right {
				display: flex;
				align-items: center;
				color: #999;

				.watch {
					color: #2892FF;
					margin-right: 20rpx;
				}

				.more {
					width: 15rpx;
					height: 15rpx;
				}

				.hash {
					margin-right: 20rpx;
				}

				.copy {
					width: 20rpx;
					height: 20rpx;
				}
			}
		}
	}

	.change {
		position: fixed;
		height: 100rpx;
		width: 750rpx;
		bottom: 0;
		left: 0;
		border-top: 1rpx solid #ededed;
		background-color: white;
		box-sizing: border-box;
		padding: 0 20rpx;
		padding-bottom: 28rpx;

		display: flex;
		align-items: center;
		justify-content: flex-end;
		flex-wrap: wrap;

		.more {
			position: absolute;
			left: 25rpx;
			font-size: 28rpx;
			color: #bbbbbb;
			top: 50%;
			transform: translateY(-50%);

			.contact {
				position: absolute;
				padding: 10rpx 20rpx;
				background-color: #333333;
				transform: translateY(-200%);
				white-space: nowrap;
				border-radius: 5rpx;
				font-size: 24rpx;

				&::before {
					content: " ";
					display: inline-block;
					border: 6rpx solid transparent;
					border-top-color: #333333;
					position: absolute;
					left: 10rpx;
					bottom: 0;
					transform: translateY(100%);
				}
			}
		}

		.btn {
			// width: 120rpx;
			height: 35rpx;
			padding: 10rpx 20rpx;
			border-radius: 30rpx;
			text-align: center;
			margin-left: 10rpx;
			font-size: 24rpx;
			color: #bbbbbb;
			border: 2rpx solid #bbbbbb;
			margin-top: 10rpx;

			&.red {
				color: #fff;
				border: 2rpx solid #ff0000;
				background-color: #ff0000;
				font-size: 32rpx;
				line-height: 32rpx;
				padding: 15rpx;
				width: 150rpx;
			}

			&.hide {
				display: none;
			}

			&.show {
				display: inline-block;
			}
		}
	}
</style>